<?

	$lFileName = $_GET['fileName'];

	if( isset( $_GET['fn'] ) ){
		$lFileName = $_GET['fn'];
	}
	
	$lCacheFolder = "thumbs/";

	if( file_exists( $lCacheFolder.$lFileName ) ){
		echo file_get_contents( $lCacheFolder.$lFileName );	

	}else{

		include("../lib/phpThumb/phpthumb.class.php");
		

		$phpThumb = new phpThumb();

		$thumbnail_width = 100;
		
		$thumbnail_height = 100;

		$phpThumb->setSourceFilename( $lFileName );

		//$phpThumb->setParameter('w', $thumbnail_width);
		$phpThumb->setParameter('h', $thumbnail_height);

		if ($phpThumb->GenerateThumbnail()) {
			$phpThumb->RenderToFile($lCacheFolder.$lFileName);
			$phpThumb->OutputThumbnail();
		

		} else {
			echo 'Failed:<pre>'.$phpThumb->fatalerror."\n\n".implode("\n\n", $phpThumb->debugmessages).'</pre>';
		}
	}
?>
